<?php
namespace app\viphry\controller;

use think\Controller;
use app\viphry\model\Member;
use app\viphry\model\AgentMember;
use think\Config;
use think\Request;

class Common extends Controller
{

    /**
     * 基础控制器初始化
     * @author hey_heyang(635870453@qq.com)
     */
    public function _initialize()
    {
        define('MODULE_NAME', request()->module());
        define('CONTROLLER_NAME', request()->controller());
        define('ACTION_NAME', request()->action());
        if(!empty(session('agent_member_id'))){
            $amModel = new AgentMember();
            $agent_member_info = $amModel->where(['id'=>session('agent_member_id')])->find();
            if(empty($agent_member_info)){
                ajaxReturn('未查询到会员信息','1',205,'');
            }
        }
        $token = request()->header('token');
        if(!empty($token) && !empty(session('agent_member_token'))){
            if($token != session('agent_member_token')){
                session('agent_member_id',null);
                session('agent_member_token',null);
                session('agent_last_login_time',null);
                ajaxReturn('账号异常请重新登录','1',206,'');
            }
        }
    }


}